<!DOCTYPE html>
<html lang="en-gb" dir="ltr" class="uk-height-1-1 uk-touch"><head>

        <title>Login</title>
    <%@ page language="java" pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@include file="basic/basic_includes.jsp" %>
    <style>
        body{
            background-color: #123;
        }
    </style>

    </head>

    <body class="uk-height-1-1">

        <div class="uk-vertical-align uk-text-center uk-height-1-1">
            <div class="uk-vertical-align-middle" style="width: 250px;">

                <%--<img class="uk-margin-bottom" width="140" height="120" src="" alt="">--%>
                <h1 style="color: #ffffaa;font-family: 幼圆; " >登录</h1>
                <form class="uk-panel uk-panel-box uk-form">
                    <div class="uk-form-row">
                        <input class="uk-width-1-1 uk-form-large" type="text" id="username" placeholder="Username">
                    </div>
                    <div class="uk-form-row">
                        <input class="uk-width-1-1 uk-form-large" type="password" id="password" placeholder="Password">
                    </div>
                    <div class="uk-form-row">
                        <a class="uk-width-1-1 uk-button uk-button-primary uk-button-large" onclick="userLogin()" >登录</a>
                    </div>
                    <div class="uk-form-row uk-text-small">
                        <label class="uk-float-left"><input type="checkbox"> Remember Me</label>
                        <a class="uk-float-right uk-link uk-link-muted" >Forgot Password?</a>
                    </div>
                </form>

            </div>
        </div>

    

</body>

<script>
    var username = $("#username").val();
    var pwd = $("#password").val();


    function initLogin(name, pwd) {
        if (isNull(name)){$("#username").focus();console.log("----username is null");}
        else if (isNull(pwd)){$("#password").focus()}
        else return true;
    }

    function userLogin() {
        var username = $("#username").val();
        var pwd = $("#password").val();
        var path = "<%=path%>";


        if (initLogin(username, pwd)) {
            $.ajax({
                url:'doLogin.html',
                type:'get',
                dataType:'json',
                data:{
                    username : username,
                    password : pwd
                },
                success : function(rd) {

                    console.log("is ---- " + rd);

                    if (rd) {
                        var newPath = path + "/index.html";
                        console.log(newPath);
                        window.location.href = path + "/index.html";
                    } else {
                        console.log("false ---- ");
                        $("#notice").css("display", "block");
                    }
                }

            })
        }
    }



    function isNull(obc) {
        return (obc == null || obc.length <= 0);
    }
</script>
</html>